<?php
//简单手机六位随机数
function phone_random(){
	$code = '';
	while (strlen($code) < 6) {
		$code .= mt_rand(0,9); // 随机起始点
	}
	return $code;
}
//sand 接口调用日志
function  sand_api_call(){
	$map['date_key'] =  date("Y-m-d");
	if(M("t_trace_no")->where($map)->find())
		M("t_trace_no")->where($map)->setInc('date_code');
	else 
		M("t_trace_no")->add($map);	
}
// 判断是否是在微信浏览器里
function isWeixinBrowser() {
	$agent = $_SERVER['HTTP_USER_AGENT'];
	if (!strpos($agent, "icroMessenger")) {
		return false;
	}
	return true;
}

//获取积分
function getCredits($cardNo) {
	$url = 'http://121.40.241.219:8080/sand/?ct=creditsBalance&no=' . $cardNo;
	$oCurl = curl_init();
	curl_setopt($oCurl, CURLOPT_URL, $url);
	curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
	$sContent = curl_exec($oCurl);
	$aStatus = curl_getinfo($oCurl);
	curl_close($oCurl);
	if (intval($aStatus["http_code"]) == 200) {
		$response = json_decode($sContent, true);
		//$creditsCache[$cardNo] = $response['qty'];
		//S('ldhcredits', $creditsCache);
		return $response['qty'];
	} else {
		return false;
	}
}

?>